﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;

namespace PhysicalExamination5.Model.DataMaintenance
{
    public class WeiHaiYinSuClass
    {
        public string? strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage ="危害因素名称是必填项！")]
        public string strWeiHaiYinSuMingCheng { get; set; }
        public string strGuoBiaoDaiMa { get; set; }
        [Required(ErrorMessage ="拼音码是必填项！")]
        public string strPym { get; set; }
        public string strWeiHaiYinSuZhongLei { get; set; }
        [Required(ErrorMessage ="所属院区是必填项！")]
        public string strSuoShuYuanQu { get; set; }
        public bool Validate(string strType, out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            switch (strType)
            {
                case "Add":
                    if (string.IsNullOrEmpty(strWeiHaiYinSuZhongLei))
                    {
                        Message.Add("危害因素种类是必填项！");
                    }
                    break;
                case "Update":
                    if (string.IsNullOrEmpty(strWeiHaiYinSuId))
                    {
                        Message.Add("危害因素ID是必填项！");
                    }
                    break;
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message);
            }
            return isSuccess;
        }
    }
    public class DeleteWeiHaiYinSuClass
    {
        [Required(ErrorMessage ="危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        public int iShunXu { get; set; }
        public bool Validate(out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            if (iShunXu == 0)
            {
                strFanHuiZhi = "顺序字段错误！";
            }
            return isSuccess;
        }
    }
    public class WeiHaiYinSuShunXuClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "危害因素种类是必填项！")]
        public string strZhongLei { get; set; }
        public int iTiaoZhengQianShunXu { get; set; }
        public int iTiaoZhengHouShunXu { get; set; }
    }
    public class WeiHaiYinSuLingCunClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "危害因素另存名称是必填项！")]
        public string strLingCunMingCheng { get; set; }
    }
    public class WeiHaiYinSuItemAddClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "岗期是必填项！")]
        public string strGangQi { get; set; }
        public List<ItemAddClass> listItem { get; set; }
        public bool Validate(out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            if (listItem == null || listItem.Count == 0)
            {
                strFanHuiZhi = "组合项目集合为空或没有数据";
            }
            return isSuccess;
        }
    }
    public class ItemAddClass
    {
        public string strZuHeXiangMuId { get; set; }
        public string strShiFouBiJian { get; set; }
    }

    public class WeiHaiYinSuItemDataClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "岗期是必填项！")]
        public string strGangQi { get; set; }
        [Required(ErrorMessage = "组合项目ID是必填项！")]
        public string strZuHeXiangMuId { get; set; }
        public string strShiFouBiJian { get; set; }
        public int iShunXu { get; set; }
        public bool Validate(string strType,out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            switch (strType)
            {
                case "Update":
                    if (string.IsNullOrEmpty(strShiFouBiJian))
                    {
                        Message.Add("是否必检是必填项！");
                    }
                    break;
                case "Delete":
                    if (iShunXu == 0)
                    {
                        Message.Add("顺序字段值错误！");
                    }
                    break;
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message);
            }
            return isSuccess;
        }
    }
    public class WeiHaiYinSuItemShunXuClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "岗期是必填项！")]
        public string strGangQi { get; set; }
        [Required(ErrorMessage = "组合项目ID是必填项！")]
        public string strZuHeXiangMuId { get; set; }
        public int iTiaoZhengQianShunXu { get; set; }
        public int iTiaoZhengHouShunXu { get; set; }
    }
    public class WeiHaiYinSuJianHuYiJuAddClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "监护依据名称是必填项！")]
        public string strJianHuYiJuMingCheng { get; set; }
    }
    public class WeiHaiYinSuJianHuYiJuDataClass
    {
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "监护依据ID是必填项！")]
        public string strJianHuYiJuID { get; set; }
        public string strJianHuYiJuMingCheng { get; set; }
        public int iShunXu { get; set; }
        public bool Validate(string strType, out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            switch (strType)
            {
                case "Update":
                    if (string.IsNullOrEmpty(strWeiHaiYinSuId))
                    {
                        Message.Add("危害因素ID是必填项！");
                    }
                    if (string.IsNullOrEmpty(strJianHuYiJuMingCheng))
                    {
                        Message.Add("监护依据名称是必填项！");
                    }
                        break;
                case "Delete":
                    if (iShunXu == 0)
                    {
                        Message.Add("顺序字段值错误！");
                    }
                    break;
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message);
            }
            return isSuccess;
        }
    }
    public class WeiHaiYinSuJianHuYiJuShunXuClass
    {
        [Required(ErrorMessage = "危害因素ID是必填项！")]
        public string strWeiHaiYinSuId { get; set; }
        [Required(ErrorMessage = "监护依据ID是必填项！")]
        public string strJianHuYiJuID { get; set; }
        public int iTiaoZhengQianShunXu { get; set; }
        public int iTiaoZhengHouShunXu { get; set; }
    }
    public class WeiHaiYinSuTongYiGengHuanItemClass
    {
        [Required(ErrorMessage = "调整前组合项目Id是必填项！")]
        public string strTiaoZhengQianZuheXiangMuId { get; set; }
        [Required(ErrorMessage = "调整后组合项目Id是必填项！")]
        public string strTiaoZhengHouZuheXiangMuId { get; set; }
        public bool Validate(out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            if (strTiaoZhengQianZuheXiangMuId.Trim() == strTiaoZhengHouZuheXiangMuId.Trim())
            {
                Message.Add("调整前后组合项目Id一致！");
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message);
            }
            return isSuccess;
        }
    }
    public class WeiHaiYinSuTongYiItemClass
    {
        [Required(ErrorMessage = "组合项目Id是必填项！")]
        public string strZuheXiangMuId { get; set; }
    }
    public class WeiHaiYinSuDuiYinBenDiItemAddClass
    {
        [Required(ErrorMessage = "国标组合项目Id是必填项！")]
        public string strGuoBiaoItemId { get; set; }
        public List<string> listBenDiItemId { get; set; }
        public bool Validate(out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            if (listBenDiItemId == null || listBenDiItemId.Count == 0)
            {
                Message.Add("本地组合项目ID集合为空！");
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message);
            }
            return isSuccess;
        }
    }
    public class WeiHaiYinSuDuiYinBenDiItemDeleteClass
    {
        [Required(ErrorMessage = "国标组合项目Id是必填项！")]
        public string strGuoBiaoItemId { get; set; }
        [Required(ErrorMessage = "本地组合项目Id是必填项！")]
        public string strBenDiItemId { get; set; }
    }
}
